<script setup lang="ts">
import {onMounted} from "vue"
import request from "@/utils/request";
import {ElMessage} from "element-plus";
import {ref} from "vue";
import { require } from "@/utils/getFileUrl"
import { useRouter } from "vue-router";



let gameList3 = ref(null)
const router = useRouter();

/*点击“游戏”跳转至游戏详情页*/
const goDetails = (game) => {
  window.open(router.resolve({ path: "/details", query: { "game": JSON.stringify(game) } }).href);
};

onMounted(()=>{
  request.get("/list-simple")
      .then(response=>{
        // response.data
        gameList3.value = response.data
      })
      .catch(error=>{
        ElMessage.error( error)

      })
})


</script>

<template>
  <div class="usercontext">
    <div class="gamecontext">
      <div class="title ">
        <div >最新动态</div>
      </div>
      <div class="game">
        <div class="getgame" v-for="(game, index) in gameList3" :key="index" >
          <div class="gameimg">
            <img :src="require( '@/assets/img/'+game.img)">

          </div>
          <div class="gamename" @click="goDetails(game)">
            <span style="font-size: 20px;color:#ecf0f1;font-family: 'Arial', sans-serif;">{{game.name}}</span>
          </div>
        </div>
      </div>
      <div class="block"></div>
      <div class="message">
        <div style="font-size: 20px;color:#ecf0f1;font-family: 'Arial', sans-serif;">留言</div>
        <el-input v-model="input" style="width: 240px" placeholder="添加一条留言" />
      </div>
    </div>
    <div class="gamelist">
      <div class="listtop">
        <span>当前在线</span>
      </div>
      <div class="Badges">
        <span>徽章</span>
      </div>
      <div class="Games">
        <span>游戏</span>
      </div>
      <div class="Inventory">
        <span>库存</span>
      </div>
      <div class="Screenshots">
        <span>截图</span>
      </div>
      <div class="Videos">
        <span>视频</span>
      </div>
      <div class="Creative">
        <span>创意工坊物品</span>
      </div>
      <div class="Reviews">
        <span>测评</span>
      </div>
      <div class="Guides">
        <span>指南</span>
      </div>
      <div class="Artworks">
        <span>艺术作品</span>
      </div>
    </div>

  </div>
</template>

<style scoped>
@import "../../assets/css/usercontext.css";
</style>